package com.dev;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.Space;
import android.widget.TextView;
import android.graphics.Typeface;
import android.app.Application;
public class ConfirmRemoveDirectory extends LinearLayout implements OnClickListener{
	WindowManager.LayoutParams wlp=new WindowManager.LayoutParams();
	LinearLayout titlebar;
	LinearLayout bottombar;
	IconViewClose ivc;
	TextView title;
	TextView msg;
	TextButton tbConfirm;
	FileBrowserTab destination;
	MainActivity ma;
    ConfirmRemoveDirectory(MainActivity ma){
		super(ma);
		this.ma=ma;
		setOrientation(VERTICAL);
		setBackgroundDrawable(new GUI.BorderDrawable());
		ivc=new IconViewClose(ma);
		ivc.setOnClickListener(this);
		title=new TextView(ma);
		title.setText("是否移除此目录标签页：");
		title.setGravity(Gravity.CENTER_VERTICAL);
		title.setTextSize(TypedValue.COMPLEX_UNIT_DIP,13);
		titlebar=new LinearLayout(ma);
		titlebar.setOrientation(HORIZONTAL);
		titlebar.setBackgroundDrawable(new GUI.BorderDrawable());
		titlebar.addView(title,-2,-1);
		titlebar.addView(new Space(ma),new LayoutParams(0,-1,1));
		titlebar.addView(ivc,-2,-1);
		titlebar.setPadding(9,0,9,0);
		tbConfirm=new TextButton(ma,"移除");
		tbConfirm.setOnClickListener(this);
		tbConfirm.borderTop=true;
		tbConfirm.borderWidth=GUI.borderWidth;
		/*bottombar=new LinearLayout(ma);
		bottombar.setOrientation(HORIZONTAL);
		bottombar.addvie*/
		msg=new TextView(ma);
		msg.setTypeface(Typeface.MONOSPACE);
		msg.setTextSize(TypedValue.COMPLEX_UNIT_DIP,13);
		msg.setTextColor(0xff0000ff);
		msg.setPadding(9,9,0,9);
		addView(titlebar,-1,(int)(30*ma.dp));
		addView(msg,-1,-2);
		addView(tbConfirm,-1,(int)(30*ma.dp));
	}
	void show(FileBrowserTab fbt){
		destination=fbt;
		wlp.width=ma.wp*4/5;
		wlp.height=-2;
		if(fbt.der==10){
			msg.setText("媒体音乐");
		}else if(fbt.der==20){
			msg.setText("媒体图像");
		}else{
			msg.setText(fbt.fbi.home.getAbsolutePath());
		}
		ma.wm.addView(this,wlp);
	}
	void dismiss(){
		ma.wm.removeView(this);
	}
	@Override
	public void onClick(View view) {
		if(view==ivc){
			dismiss();
		}else if(view==tbConfirm){
			ma.gui.removeTab(destination);
			ma.gui.saveAllTab();
			dismiss();
		}
	}
}
